<?php
/**
 * Helper class for Hello World! module
 * 
 * @package    Joomla.Tutorials
 * @subpackage Modules
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:modules/
 * @license        GNU/GPL, see LICENSE.php
 * mod_helloworld is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */
class modSlider2Helper
{
    /**
     * Retrieves the hello message
     *
     * @param array $params An object containing the module parameters
     * @access public
     */    
    function getHello( $params )
    {
        return 'Hello, World!';
    }
	
	public static function getImages(&$params) {
		//get param
		$catid = JRequest::getVar('catid',0);
		if($catid==0)
			$catid = $params->get('mycategory', '0');
		
		
        //get database
		$categories = JCategories::getInstance('Content');

		$parent = $categories->get((int) $catid);
		
		$view = JRequest::getVar('view','');
		if($view=='chitiet'){
			$catid = $parent->parent_id;
			$parent = $categories->get((int) $catid);
		}
		if(is_object($parent))
		{
			$rows = $parent->getChildren(false);
		}
		else
		{
			$rows = false;
		}	
		return $rows;
    }
	
	public static function getImagesArticles(&$params) {
		//get param
		$catid = JRequest::getVar('catid',0);
		if($catid==0)
			$catid = $params->get('mycategory', '0');
        //get database
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select($query->month($db->quoteName('created')) . ' AS created_month')
			->select('created, id, title, catid, images')
			->select($query->year($db->quoteName('created')) . ' AS created_year')
			->from('#__content')
			->where('checked_out = 0 and catid='.$catid.' and state = 1')
			->group('created_year, created_month, id, title, created');

		// Filter by language
		if (JFactory::getApplication()->getLanguageFilter())
		{
			$query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
		}

		$db->setQuery($query, 0, (int) $params->get('count'));
		$rows = (array) $db->loadObjectList();
		return $rows;
    }
}
?>